package com.icetech.eom.service.impl.sys;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.icetech.eom.dao.sys.PermissionDao;
import com.icetech.eom.domain.sys.Permission;
import com.icetech.eom.service.sys.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangzw
 * @since 2018-12-10
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionDao, Permission> implements IPermissionService {

    @Autowired
    private PermissionDao permissionDao;
    @Override
    public List<Permission> findByTypeAndStatusOrderBySortOrder(Integer type, Integer status) {
        return permissionDao.findByTypeAndStatusOrderBySortOrder(type, status);
    }

    @Override
    public List<Permission> findByUserId(Long id) {
        return permissionDao.findByUserId(id);
    }

    @Override
    public List<Permission> findByLevelOrderBySortOrder(Integer level) {
        return permissionDao.findByLevelOrderBySortOrder(level);
    }

    @Override
    public List<Permission> findByParentIdOrderBySortOrder(Long parentId) {
        return permissionDao.findByParentIdOrderBySortOrder(parentId);
    }

    @Override
    public List<Permission> findByTitle(String title) {
        return permissionDao.findByTitle(title);
    }

    @Override
    public List<Permission> findByTitleLikeOrderBySortOrder(String title) {
        return permissionDao.findByTitleLikeOrderBySortOrder(title);
    }

    @Override
    public List<Permission> getAllPermission() {
        return permissionDao.findAllPermission();
    }

    @Override
    public List<Permission> findByIdsAndLevel(List<Long> permissionIds, Integer level) {
        return permissionDao.findByIdsAndLevel(permissionIds,level);
    }

    @Override
    public List<Permission> findByButtonType(String buttonType) {
        QueryWrapper<Permission> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(Permission::getButtonType,buttonType);
        return permissionDao.selectList(queryWrapper);
    }
}
